﻿using JuCloudy.Data.Entity;
using JuCloudy.Data.Linq;
using JuCloudy.Data.Nhibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace JuSolution.Web.ApiService
{
    /// <summary>
    /// WSSysService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class WSSysService : System.Web.Services.WebService,JuCloudy.Service.Intreface.DataContainer.ISysContainer 
    {
        [WebMethod]
        public string DeleteAppInfo(string entity)
        {
            SysContainer container =
                new SysContainer();
            return container.DeleteAppInfo((SysAppInfo)entity.Deserialize(typeof(SysAppInfo))).Serialize();
        }

        [WebMethod]
        public string DeleteCategory(string entity)
        {
            SysContainer container =
                new SysContainer();

            return container.DeleteCategory(
                (SysCategory)entity
                .Deserialize(typeof(SysCategory))
                ).Serialize();
        }

        [WebMethod]
        public string DeleteStructure(string entity)
        {
            SysContainer container =
                new SysContainer();

            return container.DeleteStructure(
                (SysStructure)entity.Deserialize(typeof(SysStructure))).Serialize();
        }

        [WebMethod]
        public string GetAppInfoEntities()
        {
            SysContainer container =
                new SysContainer();
            return container.GetAppInfoEntities().Serialize();
        }

        [WebMethod]
        public string GetAppInfoEntity(int AppInfoId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetAppInfoEntity(AppInfoId).Serialize();
        }

        [WebMethod]
        public string GetAppModuleEntities(bool? IsEnable)
        {
            SysContainer container =
                new SysContainer();
            return container.GetAppModuleEntities(IsEnable).Serialize();
        }

        [WebMethod]
        public string GetAppModuleEntity(int AppModuleId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetAppModuleEntity(AppModuleId).Serialize();
        }

        [WebMethod]
        public string GetCategoryEntities()
        {
            SysContainer container =
                new SysContainer();
            return container.GetCategoryEntities().Serialize();
        }

        [WebMethod]
        public string GetCategoryEntity(int CategoryId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetCategoryEntity(CategoryId).Serialize();
        }

        [WebMethod]
        public string GetNewestAppModuleEntity(int AppId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetNewestAppModuleEntity(AppId).Serialize();
        }
        
        [WebMethod]
        public string GetStructureEntities()
        {
            SysContainer container =
                new SysContainer();

            return container.GetStructureEntities().Serialize();
        }

        [WebMethod]
        public string GetStructureEntity(int StructureId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetStructureEntity(StructureId).Serialize();
        }

        [WebMethod]
        public string GetViewEntities()
        {
            SysContainer container =
                new SysContainer();
            return container.GetViewEntities().Serialize();
        }

        [WebMethod]
        public string GetViewEntity(int StructureId)
        {
            SysContainer container =
                new SysContainer();
            return container.GetViewEntity(StructureId).Serialize();
        }

        [WebMethod]
        public string InsertAppInfo(string entity)
        {
            SysContainer container =
                new SysContainer();
            return container.InsertAppInfo((SysAppInfo)entity.Deserialize(typeof(SysAppInfo))).Serialize();
        }

        [WebMethod]
        public int InsertAppModule(string entity)
        {
            SysContainer container =
                new SysContainer();
            return container.InsertAppModule((SysAppModule)entity.Deserialize(typeof(SysAppModule)));
        }

        [WebMethod]
        public string InsertCategory(string entity)
        {
            SysContainer container =
                new SysContainer();
            return container.InsertCategory((SysCategory)entity.Deserialize(typeof(SysCategory))).Serialize();
        }

        [WebMethod]
        public string InsertStructure(string entity)
        {
            SysContainer container =
                new SysContainer();
            return container.InsertStructure((SysStructure)entity.Deserialize(typeof(SysStructure))).Serialize();
        }

        [WebMethod]
        public string WebServiceHost()
        {
            return System.Configuration.ConfigurationManager.AppSettings["WebServiceHost"];
        }
    }
}
